package JZOffer;

public class _11 {
    class Solution{
        public double Power(double base, int exponent) {
            double res = 1;
            if (exponent == 0) return 1;
            if (exponent > 0) {
                while (exponent != 0) {
                    res =  res*base;
                    exponent--;
                }
                return res;
            }
            if (exponent < 0) {
                while ((exponent != 0)) {
                    res = res*base;
                    exponent++;
                }
                return 1/res;
            }
            return res;
        }
    }

    Solution getSolution() {
        return new Solution();
    }

    public static void main(String args[]) {
        _11 c = new _11();
        _11.Solution s  = c.getSolution();
        int exponent = 3;
        double base = 3;
        System.out.println(s.Power(base,exponent));
    }
}
